//
//  WaitingView.m
//  WULIHH
//
//  Created by tang on 16/5/11.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "WaitingView.h"
#import "HUDView.h"
#import "UIWindow+WaitingView.h"

@interface WaitingView ()
{
    HUDView *hudView;
    UILabel *lable;
}

@end


@implementation WaitingView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIImageView *backImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CGFloat) ((self.frame.size.width - 100) * 0.5), (CGFloat) ((self.frame.size.height - 100) * 0.5), 100, 100)];
        [self addSubview:backImageView];
        [backImageView.layer setCornerRadius:10.0];
        [backImageView.layer setMasksToBounds:YES];
        [backImageView setImage:[UIImage imageNamed:@"waitBackimage.png"]];
        
        UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
        UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
        [effectview setFrame:backImageView.bounds];
        [backImageView addSubview:effectview];
        
        
        hudView = [[HUDView alloc] initWithFrame:CGRectMake((CGFloat) ((self.frame.size.width - 55) * 0.5),
                                                            (CGFloat) ((self.frame.size.height - 20) * 0.5), 55, 20)];
        [self addSubview:hudView];
        [hudView showAnimated:YES];

        
        lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 77.0, 100, 20.0)];
        [lable setTextAlignment:NSTextAlignmentCenter];
        [lable setTextColor:[UIColor whiteColor]];
        [backImageView addSubview:lable];
        [lable setFont:[UIFont systemFontOfSize:13.0]];
        
    }
    return self;
}


- (void)setColor:(UIColor *)color
{
    [hudView setHudColor:color];
}

- (void)setString:(NSString *)String
{
    [lable setText:String];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
